const path = require('path');
const util = require('./util');
const { config: loadConfig } = require('dotenv');

// __dirname 为当前目录文件路径

// 当前 环境
const NODE_ENV = util.getEnvironment();

//构建目录
const DIST_PATH = path.resolve(__dirname, '../../', 'dist');
//源码目录
const SRC_PATH = path.resolve(__dirname, '../../', 'src');
//public 目录
const PUBLIC_PATH = path.resolve(__dirname, '../../', 'public');
//根节点目录
const ROOT_PATH = path.resolve(__dirname, '../../');
//是否是生产环境
const IS_PRO = NODE_ENV === 'prod';
//是否是开发环境
const IS_DEV = NODE_ENV === 'dev';
//当前构建的版本
const VERSION = util.getVersion();
// 项目中需要排除的路径
const EXCLUDE_PATH = [
    path.resolve(__dirname, '../../', 'node_modules'),
];

// 加载 dotenv 环境配置
const ENV_CONFIG_PATH = path.resolve(ROOT_PATH, 'env', `${NODE_ENV}.env`);
//webpack 读取env 配置
loadConfig({
    path: ENV_CONFIG_PATH,
});
console.log('::NODE_ENV', NODE_ENV);
console.log('version', VERSION);

module.exports = {
    DIST_PATH,
    SRC_PATH,
    PUBLIC_PATH,
    ROOT_PATH,
    VERSION,
    EXCLUDE_PATH,
    IS_PRO,
    IS_DEV,
    ENV_CONFIG_PATH,
}